//
//  GQFriendView.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/7.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQFriendView.h"

@implementation GQFriendView

 -(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpChildView];
    }
    return self;
}

- (void)setUpChildView
{
    CGFloat footerViewH = 40;
    
    UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, 60, 20)];
    headerLabel.text = @"名人推荐";
    headerLabel.font = [UIFont systemFontOfSize:12];
    headerLabel.backgroundColor = [UIColor redColor];
    
    UIView *containView = [[UIView alloc] initWithFrame:CGRectMake(self.x, CGRectGetMaxY(headerLabel.frame) + 3, self.width, self.height - CGRectGetMaxY(headerLabel.frame))];
    containView.backgroundColor = [UIColor whiteColor];
    
    CGFloat viewX = 0;
    CGFloat viewMargin = 5;
    CGFloat viewY = 0;
    CGFloat viewW = self.width;
    CGFloat lineMargin = 15;
    
    CGFloat viewH = (containView.height - footerViewH) / 5 - 1;
    for (int i = 0; i < 5; i++) {
        viewY = viewMargin + i * (viewH + 2);
        UIView *tableView = [[UIView alloc] initWithFrame:CGRectMake(viewX, viewY, viewW, viewH)];
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(lineMargin, CGRectGetMaxY(tableView.frame) + 1, self.width - 2 * lineMargin, 1)];
        tableView.backgroundColor = [UIColor whiteColor];
        lineView.backgroundColor = [UIColor blackColor];
        
        CGFloat iconBtnH = 40;
        CGFloat titleLabelH = 20;
        CGFloat attentionBtnH = 25;
        CGFloat attentionBtnW = 60;
        
        //设置icon
        UIButton *iconBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, tableView.height / 2 - iconBtnH / 2, iconBtnH, iconBtnH)];
        iconBtn.backgroundColor = [UIColor redColor];
        [iconBtn setImage:[UIImage imageWithRoundName:@"icon"] forState:UIControlStateNormal];
        [tableView addSubview:iconBtn];
        
        UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(iconBtn.frame) + 10, 6, 60, 15)];
        nameLabel.text = @"杭电";
        nameLabel.font = [UIFont systemFontOfSize:14];
        nameLabel.backgroundColor = [UIColor cyanColor];
        [tableView addSubview:nameLabel];
        
        UILabel *titLabel = [[UILabel alloc] init];
        titLabel.frame = CGRectMake(CGRectGetMaxX(iconBtn.frame) + 10, tableView.height - titleLabelH - 10, 150, titleLabelH);
        titLabel.backgroundColor = [UIColor orangeColor];
        titLabel.text = @"中国书画协会名誉会长";
        titLabel.font = [UIFont systemFontOfSize:12];
        [tableView addSubview:titLabel];
        
        UIButton *attentionBtn = [[UIButton alloc] initWithFrame:CGRectMake(tableView.width - lineMargin - attentionBtnW, tableView.height / 2 - attentionBtnH / 2, attentionBtnW, attentionBtnH)];
        attentionBtn.backgroundColor = [UIColor magentaColor];
        attentionBtn.titleLabel.font = [UIFont systemFontOfSize:11];
        [attentionBtn setTitle:@"关注" forState:UIControlStateNormal];
        [tableView addSubview:attentionBtn];
        
        
        [containView addSubview:tableView];
        [containView addSubview:lineView];
    }
    
    //创建底部LookUpMore
    UIButton *moreBtn = [[UIButton alloc] initWithFrame:CGRectMake(containView.x, containView.height - footerViewH + 10, containView.width, footerViewH - 10)];
    moreBtn.backgroundColor = [UIColor whiteColor];
    [moreBtn setTitle:@"查看更多" forState:UIControlStateNormal];
    moreBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    [moreBtn setTitleColor:[UIColor redColor]forState:UIControlStateNormal];
    [containView addSubview:moreBtn];
    
    [self addSubview:headerLabel];
    [self addSubview:containView];
    
    
}

@end
